﻿#region imports

using System.Collections.Generic;

#endregion

namespace Codeplex.ODataTFS.Model.ExpressionVisitors
{
	public sealed class FilterNodeEnumerator : IEnumerator<FilterNode>
	{
		private readonly FilterNode _rootNode;
		private FilterNode _currentNode;

		public FilterNodeEnumerator(FilterNode rootNode)
		{
			_rootNode = rootNode;
		}

		public FilterNode Current
		{
			get { return _currentNode; }
		}

		object System.Collections.IEnumerator.Current
		{
			get { return _currentNode; }
		}

		public bool MoveNext()
		{
			if (_currentNode == null && _rootNode != null)
			{
				_currentNode = this._rootNode;
				return true;
			}
			else if (_currentNode != null && _currentNode.NextNode != null)
			{
				_currentNode = _currentNode.NextNode;
				return true;
			}

			return false;
		}

		public void Reset()
		{
			_currentNode = _rootNode;
		}

		public void Dispose()
		{
		}
	}
}
